﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace Brc_PaaS.Common.Model.Redis
{
    /// <summary>
    /// 操作字符串模型
    /// </summary>
    public class RedisStringModel
    {
        /// <summary>
        /// 键
        /// </summary>
        [Required(ErrorMessage = "键不能为空")]
        public string Key { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        [Required(ErrorMessage = "值不能为空")]
        public string Value { get; set; }
        /// <summary>
        /// 过期时间
        /// </summary>
        public TimeSpan? TimeSpan { get; set; }
    }
    /// <summary>
    /// 操作哈希模型
    /// </summary>
    public class RedisHashModel
    {
        /// <summary>
        /// 键
        /// </summary>
        [Required(ErrorMessage = "键不能为空")]
        public string Key { get; set; }
        /// <summary>
        /// 值（字段，key为fieldName,value为fieldValue）
        /// </summary>
        [Required(ErrorMessage = "值不能为空")]
        public Dictionary<string, string> DicValue { get; set; }
        /// <summary>
        /// 过期时间
        /// </summary>
        public TimeSpan? TimeSpan { get; set; }
    }
    /// <summary>
    /// 操作有序集合模型
    /// </summary>
    public class RedisSortSetModel
    {
        /// <summary>
        /// 键
        /// </summary>
        [Required(ErrorMessage = "键不能为空")]
        public string Key { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        [Required(ErrorMessage = "值不能为空")]
        public string Value { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        [Required(ErrorMessage = "排序不能为空")]
        public double Score { get; set; }
        /// <summary>
        /// 当前页
        /// </summary>
        [Required(ErrorMessage = "当前页不能为空")]
        [Range(1, 1000)]
        public int Page { get; set; }
        /// <summary>
        /// 每页数
        /// </summary>
        [Required(ErrorMessage = "每页显示数不能为空")]
        [Range(10, 100)]
        public int Limit { get; set; }
        /// <summary>
        /// 是否降序
        /// </summary>
        public bool IsDesc { get; set; }
    }
    /// <summary>
    /// 操作列表模型
    /// </summary>
    public class RedisListModel
    {
        /// <summary>
        /// 键
        /// </summary>
        [Required(ErrorMessage = "键不能为空")]
        public string Key { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        [Required(ErrorMessage = "值不能为空")]
        public string Value { get; set; }
        /// <summary>
        /// 操作方向
        /// </summary>
        public RedisListOperationDirection Direction { get; set; }
    }
    /// <summary>
    /// List类型数据操作的方向
    /// </summary>
    public enum RedisListOperationDirection
    {
        /// <summary>
        /// 从左开始操作
        /// </summary>
        Left = 1,
        /// <summary>
        /// 从右开始操作
        /// </summary>
        Right = 2
    }
}
